//
//  JPushUploadDeviceTokenAPI.m
//  SmartWaterFilter
//
//  Created by JianWei Chen on 16/10/8.
//  Copyright © 2016年 JianWei Chen. All rights reserved.
//

#import "JPushUploadDeviceTokenAPI.h"

@implementation JPushUploadDeviceTokenAPI
{
    NSString * _token;
}

- (id)initWithToken:(NSString *)token {
    
    if (self = [super init]) {
        _token = token;
    }
    return self;
}

- (NSString *)requestUrl {
    return @"/jpush/upload_device_token";
}

- (YTKRequestMethod)requestMethod {
    return YTKRequestMethodPOST;
}

- (id)requestArgument {
    
    NSMutableDictionary * mdict = [NSMutableDictionary getPubdic];
    [mdict setObject:_token forKey:@"device_token"];
    
    NSString *sign= [NSString getSign:mdict];
    [mdict setObject:sign forKey:@"sign"];
    
    return mdict;
}

- (BOOL)analyseResponseObject {
    
    NSDictionary *dic = [self responseJSONObject];
    NSLog(@"dict = %@",dic);
    if ([dic[@"errcode"] intValue] == 0) {
        NSLog(@"%@",dic[@"errmsg"]);
        return YES;
    } else {
        NSLog(@"%@",dic[@"errmsg"]);
        return NO;
    }
}

-(void)dealloc
{
    NSLog(@"[%@ dealloc]",NSStringFromClass(self.class));
}
@end
